uniform mat4 uMVPMatrix;
uniform mat4 uMVMatrix;
uniform vec3 uLightPosition;

attribute vec4 aPosition;
attribute vec4 aColor;
attribute vec3 aNormal;

varying vec4 vColor;

void main(){
   vec3 modelViewVertex=vec3(uMVMatrix * aPosition);
   vec3 modelViewNormal=vec3(uMVMatrix * vec4(aNormal,0.0));
   float distance=length(uLightPosition-modelViewVertex);
   vec3 lightVector=normalize(uLightPosition-modelViewVertex);
   float diffuse=max(dot(modelViewNormal,lightVector),0.1);
   diffuse=diffuse * (1.0 / (1.0+(0.25*distance*distance)));

   vColor=aColor*diffuse;
   gl_Position=uMVPMatrix*aPosition;

}